<template>
    <div>
        <el-form :model="ruleForm" status-icon ref="ruleForm" label-width="60%" label-position="left" class="demo-ruleForm">
            <el-form-item label="买家姓名" prop="buyerName">
                <el-input type="text" v-model="ruleForm.buyerName" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="买家电话" prop="buyerPhone">
                <el-input type="text" v-model="ruleForm.buyerPhone" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="退款日期" prop="returnDate">
                <el-input type="text" v-model="ruleForm.returnDate" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="退款方式" prop="returnWay">
                <el-input type="text" v-model="ruleForm.returnWay" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="退款说明" prop="returnNote">
                <el-input type="text" v-model="ruleForm.returnNote" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="退款数量" prop="returnCount">
                <el-input type="text" v-model="ruleForm.returnCount" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="退款价格" prop="returnPrice">
                <el-input type="text" v-model="ruleForm.returnPrice" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="经销商ID" prop="traderId">
                <el-input v-model.number="ruleForm.traderId"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import qs from 'qs';
    export default {
        data() {
            return {
                ruleForm: {
                    buyerName: '',
                    buyerPhone: '',
                    returnDate: '',
                    returnWay: '',
                    returnNote: '',
                    returnCount: '',
                    returnPrice: '',
                    traderId: ''
                }
            };
        },
        methods: {
            submitForm(formName) {
                var that=this;
                this.$refs[formName].validate((valid) => {
                    if (1) {
                        alert('提交成功');
                        console.log(that.ruleForm);
                        // axios({
                        //
                        //     url: 'http://localhost:8080/ocp/updateReturnOrderById',
                        //     method: 'put',
                        //     headers: {
                        //         'Content-Type':'application/json'
                        //     },
                        //     param: qs.stringify(that.ruleForm)
                        // }).then(function (resp) {
                        //     console.log(resp);
                        // })
                        axios.post('http://localhost:8080/ocp/updateReturnOrderById',qs.stringify(that.ruleForm)).then(function (resp) {
                            console.log(resp);
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        },
        created() {
            var that=this;
            axios.get('http://localhost:8080/ocp/trader/findById?tid='+this.$route.query.id).then(function (resp) {
                console.log(resp);
                that.ruleForm=resp.data.row;
            });
        }
    }
</script>

<style scoped>

</style>